﻿

Public Class cMySqlResult
    Inherits DataTable

    Private m_Count As Integer
    Public Property Count() As Integer
        Get
            Return m_Count
        End Get
        Set(value As Integer)
            m_Count = value
        End Set
    End Property

    Public Function Read(Of T)(row As Integer, columnName As String, Optional number As Integer = 0) As T
        Dim val = Rows(row)(columnName & (If(number <> 0, (1 + number).ToString(), "")))

        If GetType(T).IsEnum Then
            Return DirectCast([Enum].ToObject(GetType(T), val), T)
        End If

        Return DirectCast(Convert.ChangeType(val, GetType(T)), T)

    End Function

    Public Function ReadAllValuesFromField(columnName As String) As Object()
        Dim obj As Object() = New Object(Count - 1) {}

        For i As Integer = 0 To Count - 1
            obj(i) = Rows(i)(columnName)
        Next

        Return obj
    End Function

    Public Function ReadRow() As SortedList(Of String, sMysqlItem)
        Dim r As New SortedList(Of String, sMysqlItem)
        Stop

        Return r
    End Function

    Public Function ReadRows() As ArrayList ' of SortedList(Of String, sMysqlItem)
        Dim r As New ArrayList
        Stop

        Return r
    End Function

End Class












